import App from './App'
import { createSSRApp } from 'vue'
import yTag from './components/y-tag/y-tag.vue'
import yRadio from './components/y-radio/y-radio.vue'
import goodsItem from './components/goods-item/goods-item.vue'
import tabbar from './components/tabbar/tabbar.vue'
import listPage from './components/list-page/list-page.vue'

import * as api from './utils/api.js'
import * as adminApi from './utils/api.admin.js'
import cache from './utils/cached.js'
import * as filter from './utils/filter.js'

import uviewPlus from "uview-plus";

import * as Pinia from 'pinia';

export function createApp() {
    const app = createSSRApp(App)

    app.use(uviewPlus)

    app.config.globalProperties.$api = api
    app.config.globalProperties.$adminApi = adminApi
    app.config.globalProperties.$cache = cache
    app.config.globalProperties.$filter = filter

    // app.component('page-head', PageHead) //全局注册 page-head 组件，每个页面将可以直接使用该组件
    app.component('y-tag', yTag)
    app.component('y-radio', yRadio)
    app.component('goods-item', goodsItem)
    app.component('y-tabbar', tabbar)
    app.component('list-page', listPage)

    app.use(Pinia.createPinia());
    return {
      app,
      Pinia
    }
}
